//获取应用实例
var app = getApp()
Page({
  data: {
    topScroll: [],
    introduction:'',
    bannerIcon: [],
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 1000

  },
   onLoad: function () {
     var that=this;
     wx.request({
       url: app.globalData.weburl + app.globalData.jiekou+'/get_homepage', //仅为示例，并非真实的接口地址
       header: {
         'content-type': 'application/json'
       },
       success: function (res) {
         console.log(res);
       //轮播图
         var counttopScroll = res.data.images.length;
         for(var i=0;i<counttopScroll;i++){
           res.data.images[i] = app.globalData.weburl + res.data.images[i];
         }
         //图标
         var tubiaolength = res.data.tubiao.length;
         for (var i = 0; i < tubiaolength; i++) {
           res.data.tubiao[i]['icon_img'] = app.globalData.weburl + res.data.tubiao[i]['icon_img'];
         }
         //服务推荐
         var servicelength = res.data.service.length;
         for (var i = 0; i < servicelength; i++) {
           res.data.service[i]['images'] = app.globalData.weburl + res.data.service[i]['images'];
         }
         //关于我们 
         res.data.about['images'] = app.globalData.weburl + res.data.about['images'];
        //公司动态
         var gongsidongtai = res.data.gongsidongtai.length;
         for (var i = 0; i < gongsidongtai; i++) {
           res.data.gongsidongtai[i]['images'] = app.globalData.weburl + res.data.gongsidongtai[i]['images'];
         }
         //行业新闻
         var hanyexinwen = res.data.hanyexinwen.length;
         for (var i = 0; i < hanyexinwen; i++) {
           res.data.hanyexinwen[i]['images'] = app.globalData.weburl + res.data.hanyexinwen[i]['images'];
         }
          that.setData({
            topScroll: res.data.images,
            servicearr: res.data.service,
            aboutimages: res.data.about['images'],
            aboutcontent: res.data.about['introduction'],
            gongsidongtai: res.data.gongsidongtai,
            hanyexinwen: res.data.hanyexinwen,
            bannerIcon: res.data.tubiao
          })
       }
     })
  }, itemclick: function(res){
     wx.navigateTo({
       url: '../service/details/details?id=' + res.currentTarget.dataset.id,
     })
   }, newitemclick: function (res) {
     wx.navigateTo({
       url: '../news/newdetails/newdetails?id=' + res.currentTarget.dataset.id,
     })
   }

})